<!DOCTYPE html	PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template_layout_lrt.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<style>
.ui-button, .ui-button span, button.ui-button.ui-state-default span, .ui-button.ui-state-default span
	{
	font-weight: normal
}

#createform .ui-fileupload-content, #editForm .ui-fileupload-content {
	display: none;
}

#createform .ui-fileupload-buttonbar, #editForm .ui-fileupload-buttonbar {
	background: white;
	border: none;
}
</style>
	</ui:define>
	<ui:define name="top-box-tools">
		<h:form id="btnForm">
			<p:dialog header="文件上传" height="300" width="600" modal="true" widgetVar="uploadDialog"
				resizable="true" dynamic="true" id="uploadDialog">
				<p:outputPanel>					
					<h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
				        <p:outputLabel value="是否拆分文档?" />
				        <p:inputSwitch id="splitdoc" value="#{commonDocumentController.splitdoc}" style="margin-left:10px" >
				       		 <p:ajax/>
				        </p:inputSwitch>
	    			</h:panelGrid>
				</p:outputPanel>
				<p:fileUpload label="选择" update="form:dataTb btnForm:msgs " multiple="true" uploadLabel="上传"
					cancelLabel="取消" style="margin-top:10px"
					fileUploadListener="#{commonDocumentController.handleFileUpload}" sizeLimit="10485760"
					invalidSizeMessage="上传文件大小已超过10M" invalidFileMessage="文件格式不支持" mode="advanced"
					oncomplete="PF('uploadDialog').hide()" />
			</p:dialog>
			<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">
				<p:commandButton value="是" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" />
				<p:commandButton value="否" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
			</p:confirmDialog>
			<p:growl id="msgs" showDetail="true" />
			<div id="toolbarDiv">
				<p:toolbar id="btnBar">
					<f:facet name="left">
						<p:commandButton icon="fa fa-plus" value="新建目录"
							update="createform:createDirDialog leftForm:dirList" style="margin-left:5px;" id="createDir"
							rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_bzwdk_wdwh_xjml')}"
							disabled="#{commonDocumentController.currentSelectedNode==null}"
							oncomplete="PF('createDirDialog').show()" actionListener="#{commonDocumentController.preCreate()}" />
						<p:commandButton icon="fa fa-pencil" value="编辑目录"
							rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_bzwdk_wdwh_bjml')}"
							disabled="#{commonDocumentController.selected==null}" id="editDir"
							update="editForm:editRootDialog  leftForm:dirList" style="margin-left:5px;"
							oncomplete="PF('editRootDialog').show()" />
						<p:commandButton icon="fa fa-trash" value="删除目录"
							rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_bzwdk_wdwh_scml')}"
							disabled="#{commonDocumentController.selected==null}" id="delDir"
							update="leftForm:dirList btnBar btnForm:msgs form:dataTb" style="margin-left:5px;"
							actionListener="#{commonDocumentController.deleteDir()}">
							<p:confirm header="提示" message="删除后该目录下文件一并删除，确定删除该目录吗?" icon="ui-icon-alert" />
						</p:commandButton>
						<p:commandButton icon="ui-icon-arrowthick-1-n" value="上传文件"
							disabled="#{commonDocumentController.selected==null}"
							id="sumbitFileBtn" rendered="#{s:hasPermission(session,'dwfxpg_sbyhgl_bzwdk_wdwh_scwj')}"
							style="margin-left:5px;" oncomplete="PF('uploadDialog').show()"
							actionListener="#{commonDocumentController.preUpload()}" />
							
					<!-- 	<p:commandButton value="测试文档选择器" style="margin-left:5px;"
							actionListener="#{commonDocumentController.openDocumentSelector('evaluate')}">						
						</p:commandButton>
						
						<p:commandButton value="测试DTO构造" style="margin-left:5px;"
							actionListener="#{commonDocumentController.test()}">						
						</p:commandButton> -->
					</f:facet>
				</p:toolbar>
			</div>
		</h:form>
	</ui:define>
	<ui:define name="left-box-title">
		文档目录
	</ui:define>
	<ui:define name="left-box-body">
		<h:form id="leftForm">
			<p:tree id="dirList" value="#{commonDocumentController.root}" dynamic="true" animate="true"
				style="margin-top:5px;border:none" var="node" selectionMode="single"
				selection="#{commonDocumentController.currentSelectedNode}" widgetVar="dirList">
				<p:ajax event="select"
					update="form:dataTb btnForm:btnBar createform:createDirDialog btnForm:uploadDialog"
					listener="#{commonDocumentController.onNodeSelect}" />
				<p:ajax event="expand" update="dirList" listener="#{commonDocumentController.onNodeExpand}" />
				<p:treeNode type="rootDir" icon="fa fa-folder-open-o">
					<h:outputText value="#{node}" />
				</p:treeNode>
				<p:treeNode type="CommonDocumentDir" icon="fa fa-folder-open-o">
					<h:outputText value="#{node.name}" />
				</p:treeNode>
			</p:tree>
		</h:form>
	</ui:define>
	<div id="headDiv">
		<ui:define name="right-box-title">
		文档列表
	</ui:define>
	</div>
	<ui:define name="right-box-body">
		<div id="div1">
			<h:form id="form">
				<p:dataTable id="dataTb" emptyMessage="该目录下没有文档" draggableRows="true" editable="true"
					editMode="cell" value="#{commonDocumentController.list}" rowKey="#{record.id}" paginator="true"
					paginatorPosition="bottom" rowsPerPageTemplate="20,50,100" rows="20"
					paginatorTemplate="{Customization} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					var="record" style="text-align:center;margin-top:3px" scrollable="true">
					<f:facet name="{Customization}">
						<p:outputLabel value="总计：#{commonDocumentController.list.size()} 条记录" style="margin-right:20px;" />
					</f:facet>
					<p:ajax event="rowReorder" listener="#{commonDocumentController.onRowReorder}" update="dataTb" />
					<p:ajax event="cellEdit" listener="#{commonDocumentController.onCellEdit}" update="dataTb" />
					<p:column headerText="序号" style="text-align:center;width:52px">
						<h:outputText value="#{record.orderNo}" />
					</p:column>
					<p:column headerText="名称" style="width:40%">
						<h:outputText value="#{record.name}" />
					</p:column>
					<p:column headerText="上传时间" style="text-align:center">
						<h:outputText readonly="true" value="#{record.uploadDate}">
							<f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" timeZone="GMT+8" />
						</h:outputText>
					</p:column>
					<p:column headerText="上传人" style="text-align:center">
						<h:outputText value="#{record.uploadPerson}" />
					</p:column>
				<!-- 	<p:column headerText="年份" style="text-align:center">
						<h:outputText value="#{record.year}" />
					</p:column>
					<p:column headerText="月份" style="text-align:center">
						<h:outputText value="#{record.month}" />
					</p:column> -->
					<p:column headerText="操作" style="text-align:center">
						<p:commandLink value="下载" ajax="false" charset="utf-8"
							style="margin-left:5px;color:red;text-decoration:underline"
							actionListener="#{commonDocumentController.fileDownloadView(record)}"
							rendered="#{s:hasPermission(session,'gzgl_wdgl_wdlb_xz')}"
							oncomplete="PrimeFaces.monitorDownload(start, stop);" icon="ui-icon-arrowthick-1-s">
							<p:fileDownload value="#{commonDocumentController.file}" />
						</p:commandLink>
						<p:commandLink value="移动" style="margin-left:5px;color:red;text-decoration:underline"
							actionListener="#{commonDocumentController.moveSelectDocument(record)}"
							rendered="#{s:hasPermission(session,'gzgl_wdgl_wdlb_yd')}">
							<p:ajax event="dialogReturn" listener="#{commonDocumentController.onDirChosen}"
								update="form:dataTb" />
						</p:commandLink>
						<p:commandLink value="删除" process="@this"
							style="margin-left:5px;color:red;text-decoration:underline" update="form:dataTb btnForm:msgs"
							rendered="#{s:hasPermission(session,'gzgl_wdgl_wdlb_sc')}"
							actionListener="#{commonDocumentController.removeSelectDocument(record)}">
							<p:confirm header="提示" message="确定删除该文件吗?" icon="ui-icon-alert" />
						</p:commandLink>
					</p:column>
				</p:dataTable>
			</h:form>
		</div>
		<h:form id="createform">
			<p:dialog header="新建目录" height="300" width="400" modal="true" widgetVar="createDirDialog"
				resizable="false" dynamic="true" id="createDirDialog">
				<p:toolbar>
					<f:facet name="left">
						<p:commandButton value="保存" icon="ui-icon-disk"
							update="leftForm:dirList btnForm:msgs btnForm:btnBar createform:createDirDialog"
							oncomplete="PF('createDirDialog').hide()" actionListener="#{commonDocumentController.createDir()}"
							style="margin-left:10px" />
						<p:commandButton icon="ui-icon-cancel" type="button" value="关闭"
							onclick="PF('createDirDialog').hide()" />
					</f:facet>
				</p:toolbar>
				<p:panelGrid style="margin-top:5px; width:98%" cellpadding="4">
					<p:row>
						<p:column style="font-weight: bold;">
							<h:outputText value="名称:" />
						</p:column>
						<p:column>
							<p:inputText required="true" requiredMessage="名字不能为空"
								value="#{commonDocumentController.createDir.name}" />
						</p:column>
					</p:row>
					
					<p:row>
						<p:column style="font-weight: bold;">
							<h:outputText value="类型:" />
						</p:column>
						<p:column>
							 <p:selectOneMenu id="cdirtype" value="#{commonDocumentController.createDir.type}" style="width:125px">
					            <f:selectItem itemLabel="请选择" itemValue="" />
					            <f:selectItem itemLabel="评价标准" itemValue="evaluate" />
					            <f:selectItem itemLabel="其他类型" itemValue="other" />					            
        					</p:selectOneMenu> 
						</p:column>
					</p:row>
					<p:row>
						<p:column style="font-weight: bold;">
							<h:outputText value="备注:" />
						</p:column>
						<p:column>
							<p:inputText value="#{commonDocumentController.createDir.description}" />
						</p:column>
					</p:row>
					<!-- <p:row>
						<p:column style="font-weight: bold;">
							<h:outputText value="文档发布周期:" />
						</p:column>
						<p:column>
							<p:selectOneRadio value="#{commonDocumentController.createDir.docPublishPeriod}">
								<f:selectItem itemLabel="年" itemValue="年" />
								<f:selectItem itemLabel="月" itemValue="月" />
								<f:selectItem itemLabel="日" itemValue="日" />
							</p:selectOneRadio>
						</p:column>
					</p:row> -->
				</p:panelGrid>
			</p:dialog>
		</h:form>
		<h:form id="editForm">
			<p:dialog header="编辑目录" height="300" width="400" modal="true" widgetVar="editRootDialog"
				resizable="false" dynamic="true" id="editRootDialog">
				<p:toolbar>
					<f:facet name="left">
						<p:commandButton value="保存" icon="ui-icon-disk"
							update="leftForm:dirList btnForm:msgs btnForm:btnBar editForm:editRootDialog editForm:cdirtype "
							oncomplete="PF('createDirDialog').hide()" actionListener="#{commonDocumentController.editDir()}"
							style="margin-left:10px" />
						<p:commandButton icon="ui-icon-cancel" type="button" value="关闭"
							onclick="PF('editRootDialog').hide()" />
					</f:facet>
				</p:toolbar>
				<p:panelGrid style="margin-top:5px; width:98%" cellpadding="4">
					<p:row>
						<p:column style="font-weight: bold;">
							<h:outputText value="名称:" />
						</p:column>
						<p:column>
							<p:inputText required="true" value="#{commonDocumentController.selected.name}" />
						</p:column>
					</p:row>
					<p:row>
						<p:column style="font-weight: bold;">
							<h:outputText value="类型:" />
						</p:column>
						<p:column>
							 <p:selectOneMenu id="cdirtype" value="#{commonDocumentController.selected.type}" style="width:125px">
					            <f:selectItem itemLabel="请选择" itemValue="" />
					            <f:selectItem itemLabel="评价标准" itemValue="evaluate" />
					            <f:selectItem itemLabel="其他类型" itemValue="other" />					            
        					</p:selectOneMenu> 
						</p:column>
					</p:row>
					<p:row>
						<p:column style="font-weight: bold;">
							<h:outputText value="备注:" />
						</p:column>
						<p:column>
							<p:inputText value="#{commonDocumentController.selected.description}" />
						</p:column>
					</p:row>
					<p:row>
						<p:column style="font-weight: bold;">
							<h:outputText value="序号:" />
						</p:column>
						<p:column>
							<p:inputText value="#{commonDocumentController.selected.orderNo}" />
						</p:column>
					</p:row>
					<!-- <p:row>
						<p:column style="font-weight: bold;">
							<h:outputText value="文档发布周期:" />
						</p:column>
						<p:column>
							<p:selectOneRadio value="#{commonDocumentController.selected.docPublishPeriod}">
								<f:selectItem itemLabel="年" itemValue="年" />
								<f:selectItem itemLabel="月" itemValue="月" />
								<f:selectItem itemLabel="日" itemValue="日" />
							</p:selectOneRadio>
						</p:column>
					</p:row> -->
				</p:panelGrid>
			</p:dialog>
		</h:form>
	</ui:define>
	<ui:define name="contentend">
		<script src="/resources/js/tables/singleScrollTable.js" />
		<script>
			function hideImg() {
				document.getElementById("editForm:image").style.display = "none";
			}
		</script>
	</ui:define>
</ui:composition>